#include <stdio.h>
typedef int BTDataType;
typedef struct BinaryTreeNode
{
	BTDataType data;
	struct BinaryTreeNode* left;
	struct BinaryTreeNode* right;
}BTNode;
BTNode* BuyNode(BTDataType x)
{
	BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
	if (newnode == NULL)
	{
		perror("malloc fail");
		return NULL;
	}
	newnode->data = x;
	newnode->left = NULL;
	newnode->right = NULL;
	return newnode;
}
BTNode* CreatTree(char* a, int* pi)
{
	if (a[*pi] == '#') {
		(*pi)++;
		return NULL;
	}
	BTNode* root = BuyNode(a[*pi]);
	(*pi)++;
	root->left = CreatTree(a, pi);
	root->right = CreatTree(a, pi);
	return root;
}
void InOrder(BTNode* root)
{
	if (root == NULL)
	{

		return;
	}
	InOrder(root->left);
	printf("%c ", root->data);
	InOrder(root->right);
}
int main() {
	int i = 0;
	char a[100];
	scanf("%s", a);
	BTNode* root = CreatTree(a, &i);
	InOrder(root);
	return 0;
}